var t = getApp();

Page({
    data: {
        showTab: !1,
        confinOption: {},
        active: 0,
        disabledInquire: !0,
        InputEd: "",
        customKeyboard: null,
        customCarNumInput: null,
        customCarNumInputIndex: 0,
        list: [],
        page: 1,
        isLoadMore: !0,
        total_page: 0
    },
    onLoad: function(t) {
        t.tab && this.setData({
            active: 1
        }), this.setData({
            showTab: !0
        }), this.getConfigData(), this.getCouponList();
    },
    onReady: function() {
        this.setData({
            customKeyboard: this.selectComponent("#customKeyboard"),
            customCarNumInput: this.selectComponent("#customCarNumInput")
        });
    },
    getConfigData: function() {
        var a = this, n = t.getNetAddresss("plugin.parking-pay.frontend.coupon.index");
        t._postNetWork({
            url: n,
            data: {},
            success: function(n) {
                var o = n.data;
                1 == o.result ? a.setData({
                    confinOption: o.data
                }) : t.tips(o.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getCouponList: function() {
        var a = this, n = t.getNetAddresss("plugin.parking-pay.frontend.coupon.memberCouponList");
        t._postNetWork({
            url: n,
            data: {},
            success: function(n) {
                var o = n.data;
                1 == o.result ? a.setData({
                    list: o.data.data,
                    total_page: o.data.data.last_page,
                    isLoadMore: !0
                }) : t.tips(o.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    changeKerboard: function(t) {
        this.data.customKeyboard.change(t), this.data.customKeyboard.show();
    },
    navigateToMin: function() {
        wx.navigateToMiniProgram({
            appId: this.data.confinOption.mini_app_id,
            path: this.data.confinOption.mini_route,
            extraData: {},
            success: function(t) {},
            fail: function(t) {
                wx.showToast({
                    title: "小程序跳转失败",
                    icon: "none",
                    duration: 2e3
                });
            }
        });
    },
    goUrl: function(t) {
        var a = t.currentTarget.dataset.url;
        wx.navigateTo({
            url: a
        });
    },
    onInputFocus: function(t) {
        var a = t.detail;
        this.data.InputEd = this.data.customCarNumInput.data.numbers.map(function(t) {
            return t.value;
        }).join(""), 0 == a ? this.changeKerboard(1) : 7 == a ? this.changeKerboard(3) : this.changeKerboard(2), 
        this.setData({
            customCarNumInputIndex: a,
            disabledInquire: !(this.data.InputEd.length > 6)
        }), wx.pageScrollTo({
            selector: "#car-box",
            duration: 0
        });
    },
    onKeyboardClick: function(t) {
        this.data.customCarNumInput.change({
            index: this.data.customCarNumInputIndex,
            value: t.detail,
            remove: !1
        });
    },
    onKeyboardDelete: function(t) {
        this.data.customCarNumInput.change({
            index: this.data.customCarNumInputIndex,
            value: "",
            remove: !0
        });
    },
    toExchangeCoupon: function(t) {
        wx.navigateTo({
            url: "/packageI/parkCouponFree/exchangeCarCoupon/exchangeCarCoupon?num=" + this.data.InputEd
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.data.isLoadMore && 1 == this.data.active && this._getMoreData();
    },
    _getMoreData: function() {
        var a = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page += 1;
            var n = t.getNetAddresss("plugin.parking-pay.frontend.coupon.memberCouponList");
            n += "&page=".concat(this.data.page), t._postNetWork({
                url: n,
                success: function(t) {
                    var n = t.data;
                    if (a.data.isLoadMore = !0, 1 === n.result) {
                        var o = n.data.data.data, e = a.data.list.concat(o);
                        a.setData({
                            list: e
                        });
                    } else a.data.page = a.data.page - 1, a.data.isLoadMore = !1;
                }
            });
        }
    },
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});